<html>
 <head>
 <script type="text/javascript">
  
  var url = "json.php";
  function request() {  
    if (window.XMLHttpRequest)
     http_request = new XMLHttpRequest();
    else
     http_request = new ActiveXObject("Microsoft.XMLHTTP");
    http_request.onreadystatechange = function() {
        handle_json(http_request)
      };
    http_request.open("GET", url, true);
    http_request.send(null);
  }
  
  function handle_json(http_request) {
   if (http_request.readyState == 4) {
    document.firstForm.json.value = http_request.responseText;
    var decoded = eval("(" + http_request.responseText + ")");
    document.firstForm.decoded.value = decoded.a + "'s " +
        decoded.b + " with " + decoded.c + " at work.";
   }
  }
  
  function clearForm() {
   document.firstForm.json.value = "";
   document.firstForm.decoded.value = "";
  }
 </script>
 </head>
 <body>
  <form name="firstForm">
   <p>JSON:<br><textarea name="json" cols="50" rows="3"></textarea></p>
   <p>Decoded:<br><textarea name="decoded" cols="50" rows="3"></textarea></p>
   <input type="button" onclick="request()" value="AJAX Request">
   <input type="button" onclick="clearForm()" value="Clear">
  </form>
 </body>
 </html>